package org.jeecg.modules.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.business.entity.BussOutletQuote;
import org.jeecg.modules.business.service.IBussOutletQuoteService;
import org.jeecg.modules.business.vo.BussOutletQuoteVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

 /**
 * @Description: 出口业务报价单
 * @Author: jeecg-boot
 * @Date:   2024-05-31
 * @Version: V1.0
 */
@Api(tags="出口业务报价单")
@RestController
@RequestMapping("/business/bussOutletQuote")
@Slf4j
public class BussOutletQuoteController extends JeecgController<BussOutletQuote, IBussOutletQuoteService> {
	@Autowired
	private IBussOutletQuoteService bussOutletQuoteService;
	

	
	/**
	 *   添加
	 *
	 * @param bussOutletQuote
	 * @return
	 */
	@AutoLog(value = "出口业务报价单-添加")
	@ApiOperation(value="出口业务报价单-添加", notes="出口业务报价单-添加")
	//@RequiresPermissions("org.jeecg.modules.demo:buss_outlet_quote:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody BussOutletQuoteVo bussOutletQuote) {
		bussOutletQuoteService.saveOutletQuote(bussOutletQuote);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param bussOutletQuote
	 * @return
	 */
	@AutoLog(value = "出口业务报价单-编辑")
	@ApiOperation(value="出口业务报价单-编辑", notes="出口业务报价单-编辑")
	//@RequiresPermissions("org.jeecg.modules.demo:buss_outlet_quote:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody BussOutletQuoteVo bussOutletQuote) {
		bussOutletQuoteService.editOutletQuote(bussOutletQuote);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "出口业务报价单-通过id删除")
	@ApiOperation(value="出口业务报价单-通过id删除", notes="出口业务报价单-通过id删除")
	//@RequiresPermissions("org.jeecg.modules.demo:buss_outlet_quote:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		bussOutletQuoteService.removeById(id);
		return Result.OK("删除成功!");
	}
	

	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	//@AutoLog(value = "出口业务报价单-通过id查询")
	@ApiOperation(value="出口业务报价单-通过id查询", notes="出口业务报价单-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<BussOutletQuote> queryById(@RequestParam(name="id",required=true) String id) {
		BussOutletQuote bussOutletQuote = bussOutletQuoteService.getById(id);
		if(bussOutletQuote==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(bussOutletQuote);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param bussOutletQuote
    */
    //@RequiresPermissions("org.jeecg.modules.demo:buss_outlet_quote:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, BussOutletQuote bussOutletQuote) {
        return super.exportXls(request, bussOutletQuote, BussOutletQuote.class, "出口业务报价单");
    }

    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    //@RequiresPermissions("buss_outlet_quote:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, BussOutletQuote.class);
    }

	 @ApiOperation(value="出口业务报价单-通过评审id查询", notes="出口业务报价单-通过评审id查询")
	 @GetMapping(value = "/queryByReviewId")
	 public Result<BussOutletQuoteVo> queryByReviewId(@RequestParam(name="id",required=true) String id) {
		 BussOutletQuoteVo bussOutletQuote = bussOutletQuoteService.queryByReviewId(id);
		 if(bussOutletQuote==null) {
			 return Result.error("未找到对应数据");
		 }
		 return Result.OK(bussOutletQuote);
	 }
}
